<template>
	<view class="container" style="background-color: #FFF;height: 100vh;">
		<view style="display: flex;flex-direction: row;align-items: center; padding-top: 150rpx;margin-left: 150rpx;">
			<image v-if="userInfo.avatarUrl" style="width: 100rpx;height: 100rpx;border-radius: 10rpx;" :src="userInfo.avatarUrl"
			 mode="aspectFill"></image>
			<view class="content" style="margin-left: 16rpx;">
				<view class="nickname" v-if="userInfo.nickname">{{userInfo.nickname}}</view>
				<view class="nickname" v-if="userInfo.code">推荐码：{{userInfo.code}}</view>
			</view>
		</view>
		<view style="margin-top: 20px;margin-left: 110rpx;">
			<image style="width: 530rpx;height: 530rpx;" :src="'data:image/png;base64,' + base64_code" mode="aspectFill"></image>
		</view>
		<view style="width: 250rpx;margin-top: 40rpx;margin-left: 250rpx;">
			<button type="primary" open-type='share'>
				分享
			</button>
		</view>
	</view>
</template>

<script>
	import { shop } from '@/api/shop.js'
	import { common } from '@/api/common.js'
	export default{
		components: {},
		data() {
			return {
				userInfo: {},
				base64_code: '',
				regUrl: ''
			}
		},
		onLoad() {
			this.userInfo = this.$storage.getStorageDataSync(this.$store.state.userInfo)
			var clientInfo = this.$storage.getStorageDataSync(this.$store.state.clientInfo)
			this.regUrl = clientInfo.baseUrl + '?clientname='+this.$store.state.clientname + '&CHN=regCode'+'&parentCode=' + this.userInfo.code
			this.createCode(this.regUrl)
		},
		onShareAppMessage(res) {
			return {
				title: '',
				path:  '/pages/login/reg'+ '?parentCode=' + this.userInfo.code
			}
		},
		methods:{
			createCode(content) {
				common.createCode({
					content: content 
				}).then(res => {
					if (res.data.code == 10000) {
						this.base64_code = res.data.data
					}
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	
</style>
